class AppendStringPlugin {    
    constructor(options) {
      this.options = options;
    }
  
    apply(compiler) {
      compiler.hooks.emit.tapAsync('AppendStringPlugin', (compilation, callback) => {
        // 获取要修改的输出文件
        const outputFile = this.options.filename;
        const asset = compilation.assets[outputFile];
  
        if (asset) {
          // 在文件内容末尾添加字符串
          const originalSource = asset.source();
          const appendedSource = `${originalSource}${this.options.stringToAppend}`;
  
          // 更新文件内容
          compilation.assets[outputFile] = {
            source: () => appendedSource,
            size: () => appendedSource.length,
          };
        }
  
        // 继续执行其他插件和 Webpack 的后续步骤
        callback();
      });
    }
  }
  
  module.exports = AppendStringPlugin;
  